// pages/movie-detail/movie-detail.js
const {getMovieDetail} = require("../../model/movieData")
const {getMovieCollect} = require("../../model/moviehttp")
Page({
  data: {
    result:"",
    id:"",
    keyword:""
  },
  onLoad:async function (options) {
    var {id,keyword} = options;
    getMovieDetail(id).then(res=>{
      var result = res.data.res
      this.setData({result,keyword,id})
    })
    wx.setNavigationBarTitle({
      title: '电影详情',
    });
  },
  handleChange(){
    var result = this.data.result
    result[0].collected = !result[0].collected
    var keyword = this.data.keyword;
    console.log(keyword)
    // console.log(this.data.id)
    this.setData({result})
    console.log(this.data.result[0].collected)
    getMovieCollect({
      url:`api/collectMovie/${keyword}`,
      id:this.data.id,
      collected:this.data.result[0].collected,
      success:res=>{console.log(res)}
    })
  }
})